import { ResPage, SysSequenceRule } from "@/api/interface/index";
import { CANROCNET } from "@/api/config/servicePort";
import http from "@/api";

/**
 * 新增序列规则
 *
 * @param params 序列规则表单
 * @returns 返回是否成功
 */
export const addSequenceRuleApi = (params: SysSequenceRule.Form) => {
  return http.post<boolean>(`${CANROCNET}/api/sys-sequence-rule/addition`, params);
};

/**
 * 编辑序列规则
 *
 * @param params 序列规则表单
 * @returns 返回是否成功
 */
export const editSequenceRuleApi = (params: SysSequenceRule.Form) => {
  return http.post<boolean>(`${CANROCNET}/api/sys-sequence-rule/edit`, params);
};

/**
 * 启用/禁用序列规则
 *
 * @param params 序列规则Id
 * @returns 返回是否成功
 */
export const switchEnableSequenceRuleApi = (params: { id: string }) => {
  return http.post<boolean>(`${CANROCNET}/api/sys-sequence-rule/enable`, params);
};

/**
 * 删除序列规则
 *
 * @param params 序列规则Id
 * @returns 返回是否成功
 */
export const deleteSequenceRuleApi = (params: { ids: string[] }) => {
  return http.post<boolean>(`${CANROCNET}/api/sys-sequence-rule/del`, params);
};

/**
 * 获取序列规则列表
 *
 * @param params 序列规则查询参数
 * @returns 返回序列规则列表
 */
export const getSequenceRulePageApi = (params: SysSequenceRule.PageParams) => {
  return http.get<ResPage<SysSequenceRule.Result>>(`${CANROCNET}/api/sys-sequence-rule/page`, params);
};
